import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse, Polygon

# 设置中文字体（使用之前确认的字体路径）
from matplotlib.font_manager import FontProperties
font_path = "/usr/share/fonts/truetype/arphic/ukai.ttc"  # 替换为你的字体路径
chinese_font = FontProperties(fname=font_path)

# 创建空白画布
fig, ax = plt.subplots(figsize=(6, 4))
ax.set_xlim(0, 10)
ax.set_ylim(0, 8)
ax.axis('off')

# 随机颜色（身体、翅膀、头部）
body_color = np.random.rand(3)  # RGB随机颜色
wing_color = np.random.rand(3)
head_color = np.random.rand(3)

# 绘制鸟身体（椭圆）
body = Ellipse(xy=(5, 4), width=6, height=2, color=body_color)
ax.add_patch(body)

# 绘制翅膀（多边形）
wing_points = np.array([
    [3, 4], [5, 5.5], [7, 4]  # 随机调整翅膀形状
]) + np.random.normal(0, 0.3, (3, 2))  # 加入随机扰动
wing = Polygon(wing_points, color=wing_color)
ax.add_patch(wing)

# 绘制头部（圆形）
head = Ellipse(xy=(8, 4), width=2, height=2, color=head_color)
ax.add_patch(head)

# 绘制眼睛（黑点）
ax.plot(8.5, 4.2, 'ko', markersize=5)

# 绘制喙（三角形）
beak = Polygon(np.array([[9, 4], [10, 4.2], [9, 3.8]]), color='orange')
ax.add_patch(beak)

# 标题
plt.title('随机抽象鸟类图像', fontproperties=chinese_font)
plt.tight_layout()
plt.show()

